﻿using System;
using System.Collections.Generic;
using System.Text;
using KenLib.Dal;
using DataInfo;
using XBLib.Dal.AdoDal;
using System.Data;
using System.Data.Common;

namespace KenLib.Dal
{
    public class frm_AppCompListDao : BaseAdoDao
    {
        public List<本社情報> GetAllData(int ID)
        {
            DbParameter prid = _daoHelper.CreateParameter("@OrgID", ID, DbType.Int32);
            DbCommand command = _daoHelper.CreateCommand(CommandNameManager.usp_SelectAppComByOrgID, CommandType.StoredProcedure, prid);
            return _businessObjectHelper.FillToList<本社情報>(_daoHelper.Query(command));
            //return null;

        }

        public List<本社情報> GetDataWithSearchLike(int ID, string query)
        {
            DbParameter prid = _daoHelper.CreateParameter("@OrgID", ID, DbType.Int32);
            DbParameter prquery = _daoHelper.CreateParameter("@QUERY", query, DbType.String);
            DbCommand command = _daoHelper.CreateCommand(CommandNameManager.usp_SelectAppComByOrgIDAndQuery, CommandType.StoredProcedure, prid, prquery);
            return _businessObjectHelper.FillToList<本社情報>(_daoHelper.Query(command));
            //return null;
        }
        public string GetIdByOrgId(string id)
        {
            string idcom = "";
            DbParameter prid = _daoHelper.CreateParameter("@id", id, DbType.String);
            DbCommand command = _daoHelper.CreateCommand(CommandNameManager.GetIdComByOrgID_Luan, CommandType.StoredProcedure, prid);
            if (_daoHelper.ExecuteScalar(command) == null)
            {
                idcom = "";
            }
            else
            {
                idcom = _daoHelper.ExecuteScalar(command).ToString();
            }           
            return idcom;

        }
        public List<本社情報> Select本社情報_Luan()
        {
            DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Select本社情報_Luan, CommandType.StoredProcedure);
            return _businessObjectHelper.FillToList<本社情報>(_daoHelper.Query(command));
        }
    }
}
